﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using T_Rbac_APi.Application.Command.Jobs;

namespace T_Rbac_APi.Controllers
{
    /// <summary>
    /// 角色
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class JobController : ControllerBase
    {
        private readonly IMediator mediator;

        public JobController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 角色添加
        /// </summary>
        /// <param name="jobAddCommand"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> JobAdd(JobAddCommand jobAddCommand)
        {
            return await mediator.Send(jobAddCommand);
        }
        /// <summary>
        /// 角色删除
        /// </summary>
        /// <param name="jobDeleteCommand"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> DeleteJob([FromQuery]JobDeleteCommand jobDeleteCommand)
        {
            return await mediator.Send(jobDeleteCommand);
        }
        /// <summary>
        /// 角色批量删除
        /// </summary>
        /// <param name="jobDeleteListCommand"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> DeleteListJob([FromQuery]JobDeleteListCommand jobDeleteListCommand)
        {
            return await mediator.Send(jobDeleteListCommand);
        }
        /// <summary>
        /// 角色修改
        /// </summary>
        /// <param name="jobUpdateCommand"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int>UpdateJob(JobUpdateCommand jobUpdateCommand)
        {
            return await mediator.Send(jobUpdateCommand);
        }
    }
}
